home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performSubdProjectionArgList < prev    next >
Encoding:
Text File  |  2003-07-17  |  23.7 KB  |  679 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //  Alias|Wavefront Script File
  18. //  MODIFY THIS AT YOUR OWN RISK
  19. //
  20. //  Creation Date:  25 January 2001
  21. //  Based on performPolyProjectionArgList.mel
  22. //
  23. //  Procedure Name:
  24. //      performSubdProjection
  25. //
  26. //  Description:
  27. //        adds a planar, cylindric or spheric projection to the selected subd facets
  28. //         
  29. //  Input Arguments:
  30. //        $option : Whether to set the options to default values.
  31. //  Return Value:
  32. //        command string iff $option==2
  33. //
  34. // NOTE: create UV map is not implemented for the time being. This file has
  35. //    places where it would be implemented appearing as comments.
  36. //
  37.  
  38. proc string argArrayAsString (string $args[])
  39. {
  40.     string $result = "{";
  41.     string $cast = "(string)";
  42.     for ($arg in $args) {
  43.         $result += ($cast + "\"" + $arg + "\"");
  44.         $cast = ", ";
  45.     }
  46.     return ($result + "}");
  47. }
  48.  
  49. proc setOptionVars (string $primitive, int $forceFactorySettings)
  50. {
  51.      // -icx/-imageCenterX  -icy/-imageCenterY 
  52.     if ($forceFactorySettings || !`optionVar -exists ("subdProjectionImageCenter" + $primitive)`)
  53.         optionVar -floatValue ("subdProjectionImageCenter" + $primitive) 0.5
  54.             -floatValueAppend ("subdProjectionImageCenter" + $primitive) 0.5;
  55.      
  56.     // -pcx/-projectionCenterX     -pcy/-projectionCenterY    -pcz/-projectionCenterZ
  57.     if ($forceFactorySettings || !`optionVar -exists ("subdProjectionCenter" + $primitive)`)
  58.         optionVar -floatValue ("subdProjectionCenter" + $primitive) 0.
  59.             -floatValueAppend ("subdProjectionCenter" + $primitive) 0.
  60.             -floatValueAppend ("subdProjectionCenter" + $primitive) 0.;
  61.  
  62.     // -rx/-rotateX  -ry/-rotateY  -rz/-rotateZ 
  63.     if ($forceFactorySettings || !`optionVar -exists ("subdProjectionRotate" + $primitive)`)
  64.         optionVar -floatValue ("subdProjectionRotate" + $primitive) 0.
  65.             -floatValueAppend ("subdProjectionRotate" + $primitive) 0.
  66.             -floatValueAppend ("subdProjectionRotate" + $primitive) 0.;
  67.  
  68.      // -pw/-projectionScaleU  -ph/-projectionScaleV 
  69.     if ($primitive != "Planar") {
  70.         float $fval1=180.;
  71.         float $fval2=90.0;
  72.         if ($primitive == "Cylindrical") $fval2=1.0;
  73.         if ($forceFactorySettings || !`optionVar -exists ("subdProjectionScaleU" + $primitive)`) 
  74.             optionVar   -floatValue ("subdProjectionScaleU" + $primitive) $fval1;
  75.         if ($forceFactorySettings || !`optionVar -exists ("subdProjectionScaleV" + $primitive)`) 
  76.             optionVar   -floatValue ("subdProjectionScaleV" + $primitive) $fval2;
  77.     } else {
  78.         if ($forceFactorySettings || !`optionVar -exists ("subdProjectionScale" + $primitive)`) {
  79.             optionVar -floatValue ("subdProjectionScale" + $primitive) 1.
  80.                 -floatValueAppend ("subdProjectionScale" + $primitive) 1.;
  81.         }
  82.     }
  83.  
  84.     if ($forceFactorySettings || !`optionVar -exists ("subdProjectionSmartFit" + $primitive)`) {
  85.         optionVar -intValue ("subdProjectionSmartFit" + $primitive) 1;
  86.     }
  87.  
  88.     if ($forceFactorySettings || !`optionVar -exists ("subdProjectionFitToBoxOrPlane" + $primitive)`) {
  89.         optionVar -intValue ("subdProjectionFitToBoxOrPlane" + $primitive) 2;
  90.     }
  91.  
  92.     if ($forceFactorySettings || !`optionVar -exists ("subdProjectionMappingDirection" + $primitive)`) {
  93.         optionVar -intValue ("subdProjectionMappingDirection" + $primitive) 3;
  94.     }
  95.  
  96.     if ($forceFactorySettings || !`optionVar -exists ("subdProjectionInsertionPoint" + $primitive)`) {
  97.         optionVar -intValue ("subdProjectionInsertionPoint" + $primitive) 1;
  98.     }
  99.  
  100.     // -isu/-imageScaleU  -isv/-imageScaleV 
  101.     if ($forceFactorySettings || !`optionVar -exists ("subdProjectionImageScale" + $primitive)`)
  102.         optionVar -floatValue ("subdProjectionImageScale" + $primitive) 1.
  103.             -floatValueAppend ("subdProjectionImageScale" + $primitive) 1.;
  104.  
  105.     //  -ra/-rotationAngle 
  106.     if ($forceFactorySettings || !`optionVar -exists ("subdProjectionRotationAngle" + $primitive)`)
  107.         optionVar -floatValue ("subdProjectionRotationAngle" + $primitive) 0.;
  108.  
  109.     if ($primitive == "Planar")
  110.         if ($forceFactorySettings || !`optionVar -exists ("subdProjectionSquareImage" + $primitive)`)
  111.             optionVar -intValue ("subdProjectionSquareImage" + $primitive) 0;
  112.  
  113. /*
  114. createMap omitted for now
  115.  
  116.     // -cm/-createMap
  117.     if ($forceFactorySettings || !`optionVar -exists ("subdProjectionCreateMap" + $primitive)`)
  118.         optionVar -intValue ("subdProjectionCreateMap" + $primitive) 0;        
  119.     // -uvs/-uvSetName
  120.     if ($forceFactorySettings || !`optionVar -exists ("subdProjectionUvSetName" + $primitive)`)
  121.         optionVar -stringValue ("subdProjectionUvSetName" + $primitive) "uvSet1";        
  122. */
  123. }
  124.  
  125. global proc performSubdProjectionSetup (string $primitive, string $parent, int $forceFactorySettings)
  126. {
  127.     setOptionVars($primitive, $forceFactorySettings);
  128.     setParent $parent;
  129.     float $vals[];
  130.     float $val;
  131.  
  132.     $vals = `optionVar -query ("subdProjectionImageCenter" + $primitive)`;
  133.      floatFieldGrp -edit -value1 $vals[0] -value2 $vals[1] subdProjectionImageCenter;
  134.  
  135.     $vals = `optionVar -query ("subdProjectionRotate" + $primitive)`;
  136.      floatFieldGrp -edit -value1 $vals[0] -value2 $vals[1] -value3 $vals[2] subdProjectionRotate;
  137.  
  138.     $vals = `optionVar -query ("subdProjectionCenter" + $primitive)`;
  139.      floatFieldGrp -edit -value1 $vals[0] -value2 $vals[1] -value3 $vals[2] subdProjectionCenter;
  140.  
  141.         $val = `optionVar -query ("subdProjectionScaleU" + $primitive)`;
  142.          floatSliderGrp -edit -value $val subdProjectionScaleU;
  143.         $val = `optionVar -query ("subdProjectionScaleV" + $primitive)`;
  144.          floatSliderGrp -edit -value $val subdProjectionScaleV;
  145.  
  146.     checkBoxGrp -edit -value1
  147.         `optionVar -q ("subdProjectionSmartFit" + $primitive)`
  148.             subdProjectionSmartFit;
  149.     
  150.     checkBoxGrp -edit -value1
  151.         `optionVar -q ("subdProjectionInsertionPoint" + $primitive)`
  152.             subdProjectionInsertionPoint;
  153.     
  154.     if ($primitive == "Planar") {
  155.         radioButtonGrp -edit -select
  156.             `optionVar -q ("subdProjectionFitToBoxOrPlane" + $primitive)`
  157.             subdProjectionFitToBoxOrPlane;
  158.     
  159.         radioButtonGrp -edit -select 
  160.             `optionVar -q ("subdProjectionMappingDirection" + $primitive)`
  161.             subdProjectionMappingDirection;
  162.     }
  163.     
  164.     if (`checkBoxGrp -query -value1 subdProjectionSmartFit`) 
  165.             subdEnableSmartFit $primitive;    
  166.     else     subdDisableSmartFit $primitive;
  167.  
  168.     $vals = `optionVar -query ("subdProjectionImageScale" + $primitive)`;
  169.      floatFieldGrp -edit -value1 $vals[0] -value2 $vals[1] subdProjectionImageScale;
  170.  
  171.     $val=`optionVar -query ("subdProjectionRotationAngle" + $primitive)`;
  172.      floatSliderGrp -edit -value $val subdProjectionRotationAngle;
  173.     
  174.     if ($primitive == "Planar")
  175.         checkBoxGrp -edit -value1 
  176.             `optionVar -q ("subdProjectionSquareImage" + $primitive)`
  177.                 subdProjectionSquareImage;
  178.  
  179. /*
  180. createMap omitted for now
  181.  
  182.     $val = `optionVar -q ("subdProjectionCreateMap" + $primitive)`;
  183.     checkBoxGrp -edit -value1 $val subdProjectionCreateMap;
  184.     if ($val == 1)
  185.         disable -v false subdProjectionUvSetName;
  186.     else
  187.         disable -v true subdProjectionUvSetName;
  188.     textFieldGrp -edit -tx 
  189.         `optionVar -q ("subdProjectionUvSetName" + $primitive)`        
  190.         subdProjectionUvSetName;
  191. */
  192. }
  193.  
  194. global proc performSubdProjectionCallback (string $primitive, string $args[], string $uvSetName, string $parent, int $doIt)
  195. {
  196.     setParent $parent;
  197.     
  198.     optionVar -floatValue ("subdProjectionImageCenter" + $primitive)
  199.         `floatFieldGrp -query -value1 subdProjectionImageCenter`
  200.         -floatValueAppend ("subdProjectionImageCenter" + $primitive)
  201.         `floatFieldGrp -query -value2 subdProjectionImageCenter`;
  202.     
  203.     optionVar -floatValue ("subdProjectionCenter" + $primitive)
  204.         `floatFieldGrp -query -value1 subdProjectionCenter`
  205.         -floatValueAppend ("subdProjectionCenter" + $primitive)
  206.         `floatFieldGrp -query -value2 subdProjectionCenter`
  207.         -floatValueAppend ("subdProjectionCenter" + $primitive)
  208.         `floatFieldGrp -query -value3 subdProjectionCenter`;
  209.         
  210.     optionVar -floatValue ("subdProjectionRotate" + $primitive)
  211.         `floatFieldGrp -query -value1 subdProjectionRotate`
  212.         -floatValueAppend ("subdProjectionRotate" + $primitive)
  213.         `floatFieldGrp -query -value2 subdProjectionRotate`
  214.         -floatValueAppend ("subdProjectionRotate" + $primitive)
  215.         `floatFieldGrp -query -value3 subdProjectionRotate`;
  216.         
  217.         optionVar -floatValue ("subdProjectionScaleU" + $primitive)
  218.             `floatSliderGrp -query -value subdProjectionScaleU`;
  219.         optionVar -floatValue ("subdProjectionScaleV" + $primitive)
  220.             `floatSliderGrp -query -value subdProjectionScaleV`;
  221.     
  222.     optionVar -intValue ("subdProjectionSmartFit" + $primitive)
  223.         `checkBoxGrp -query -value1 subdProjectionSmartFit`;
  224.  
  225.     if (`checkBoxGrp -query -value1 subdProjectionSmartFit`) 
  226.             subdEnableSmartFit $primitive;    
  227.     else     subdDisableSmartFit $primitive;
  228.  
  229.     if ($primitive == "Planar") {
  230.         optionVar -intValue ("subdProjectionFitToBoxOrPlane" + $primitive)
  231.             `radioButtonGrp -query -select subdProjectionFitToBoxOrPlane`;
  232.  
  233.         optionVar -intValue ("subdProjectionMappingDirection" + $primitive)
  234.             `radioButtonGrp -query -select subdProjectionMappingDirection`;
  235.     }
  236.  
  237.     optionVar -intValue ("subdProjectionInsertionPoint" + $primitive)
  238.         `checkBoxGrp -query -value1 subdProjectionInsertionPoint`;
  239.  
  240.     optionVar -floatValue ("subdProjectionImageScale" + $primitive)
  241.         `floatFieldGrp -query -value1 subdProjectionImageScale`
  242.         -floatValueAppend ("subdProjectionImageScale" + $primitive)
  243.         `floatFieldGrp -query -value2 subdProjectionImageScale`;
  244.     
  245.     optionVar -floatValue ("subdProjectionRotationAngle" + $primitive)
  246.         `floatSliderGrp -query -value subdProjectionRotationAngle`;
  247.         
  248.     if ($primitive == "Planar")
  249.         optionVar -intValue ("subdProjectionSquareImage" + $primitive)
  250.             `checkBoxGrp -query -value1 subdProjectionSquareImage`;
  251.  
  252. //createMap omitted for now
  253.  
  254. //    optionVar -intValue ("subdProjectionCreateMap" + $primitive)
  255. //         `checkBoxGrp -query -value1 subdProjectionCreateMap`;
  256. //    optionVar -stringValue ("subdProjectionUvSetName" + $primitive)
  257. //         `textFieldGrp -query -tx subdProjectionUvSetName`;
  258.  
  259.     if ($doIt) {
  260.         $args[0] = "0";
  261.         performSubdProjectionArgList 1 $args $uvSetName;
  262.         string $tmpCmd = "performSubdProjection \"" + $primitive + "\" 0";
  263.         string $tmpCmdLabel = "subdProjection";
  264.         if ($primitive == "Planar") $tmpCmdLabel = "subdPlanarProjection";
  265.         else if ($primitive == "Cylindrical") $tmpCmdLabel = "subdCylindricalProjection";
  266.         else if ($primitive == "Spherical") $tmpCmdLabel = "subdSphericalProjection";
  267.         addToRecentCommandQueue $tmpCmd $tmpCmdLabel;
  268.     }
  269. }
  270.  
  271. global proc subdDisableSmartFit(string $primitive)
  272. {
  273.     subdEnableProjectionTransformation($primitive);
  274.     if ($primitive == "Planar")     {    
  275.         disable subdProjectionMappingDirection;
  276.         disable subdProjectionFitToBoxOrPlane;
  277.         disable subdProjectionSquareImage;
  278.     }
  279. }
  280.  
  281. global proc subdEnableSmartFit(string $primitive)
  282. {
  283.     subdDisableProjectionTransformation($primitive);
  284.     if ($primitive == "Planar")    {
  285.         disable -v false subdProjectionFitToBoxOrPlane;
  286.         disable -v false subdProjectionSquareImage;
  287.     }
  288.  
  289.     if ($primitive != "Planar")    return;
  290.  
  291.     int $res = `radioButtonGrp -query -select subdProjectionFitToBoxOrPlane`;
  292.     if ($res == 2)
  293.             disable -v false subdProjectionMappingDirection;
  294.     else     disable subdProjectionMappingDirection;
  295. }
  296.  
  297. global proc subdDisableProjectionTransformation(string $primitive)
  298. {
  299.     disable subdProjectionCenter;
  300.     disable subdProjectionRotate;
  301.     disable subdProjectionScaleU;
  302.     disable subdProjectionScaleV;
  303.     return;
  304. }
  305.  
  306. global proc subdEnableProjectionTransformation(string $primitive)
  307. {
  308.     disable -v false subdProjectionCenter;
  309.     disable -v false subdProjectionRotate;
  310.     disable -v false subdProjectionScaleU;
  311.     disable -v false subdProjectionScaleV;
  312.     return;
  313. }
  314.  
  315. global proc subdEnableMappingDirection()
  316. {
  317.     disable -v false subdProjectionMappingDirection;
  318. }
  319.  
  320. global proc subdEnableFitToBoxOrPlane()
  321. {
  322.     disable -v false subdProjectionFitToBoxOrPlane;
  323. }
  324.  
  325. proc subdProjectionOptions (string $primitive, string $args[], string $uvSetName)
  326. {
  327.     string $layout = getOptionBox();
  328.     setParent $layout;
  329.     setUITemplate -pushTemplate DefaultTemplate;
  330.     waitCursor -state 1;
  331.     tabLayout -scr true -tv false;
  332.     
  333.     string $parent = `columnLayout -adjustableColumn 1`;
  334.  
  335.     string $commandName = "performSubdProjection";
  336.     string $callback = ($commandName + "Callback " + $primitive + " " + argArrayAsString ($args) + " \"" + $uvSetName + "\" " + $parent + " ");
  337.     string $setup = ($commandName + "Setup " + $primitive + " " + $parent + " ");
  338.     
  339.     floatFieldGrp -label "Projection Center" -numberOfFields 3 subdProjectionCenter;
  340.     floatFieldGrp -label "Projection Rotation" -numberOfFields 3 subdProjectionRotate;
  341.  
  342.     if ($primitive == "Planar") {
  343.         floatSliderGrp -label "Projection Width" -min 0.0 -max 100.0 
  344.                             subdProjectionScaleU;
  345.         floatSliderGrp -label "Projection Height" -min 0.0 -max 100.0 
  346.                             subdProjectionScaleV;
  347.     } else if ($primitive == "Cylindrical") {
  348.         floatSliderGrp -label "Projection Horizontal Sweep" -min 0.0 -max 360.0 
  349.                             subdProjectionScaleU;
  350.         floatSliderGrp -label "Projection Height" subdProjectionScaleV;
  351.     } else {
  352.         // spherical
  353.         floatSliderGrp -label "Projection Horizontal Sweep" -min 0.0 -max 360.0 
  354.                             subdProjectionScaleU;
  355.         floatSliderGrp -label "Projection Vertical Sweep" -min 0.0 -max 180.0 
  356.                             subdProjectionScaleV;
  357.     }
  358.  
  359.     separator;
  360.  
  361.     checkBoxGrp    -label "Smart Fit" -label1 "Automatically Fit the Projection Manipulator"
  362.                 -onc ("subdEnableSmartFit " + $primitive)
  363.                 -ofc ("subdDisableSmartFit " + $primitive)
  364.                 subdProjectionSmartFit;
  365.  
  366.     if ($primitive == "Planar") {
  367.         radioButtonGrp -nrb 2 -label1 "Fit to Best Plane" -label2 "Fit to Bounding Box"
  368.                     -on1 ("disable subdProjectionMappingDirection")
  369.                     -of1 ("subdEnableMappingDirection")
  370.                     subdProjectionFitToBoxOrPlane;
  371.  
  372.         radioButtonGrp -nrb 4 -label "Mapping Direction"
  373.                         -label1 "X Axis" -label2 "Y Axis" -label3 "Z Axis" -label4 "Camera"
  374.                         subdProjectionMappingDirection;
  375.     }
  376.  
  377.     checkBoxGrp -label1 "Insert Before Deformers" subdProjectionInsertionPoint;
  378.  
  379.     separator;
  380.  
  381.     floatFieldGrp -label "Image Center" -numberOfFields 2 subdProjectionImageCenter;
  382.     floatSliderGrp -label "Image Rotation" -min 0.0 -max 360.0 subdProjectionRotationAngle;    
  383.     floatFieldGrp -label "Image Scale" -numberOfFields 2 subdProjectionImageScale;
  384.  
  385.     if ($primitive == "Planar")        
  386.         checkBoxGrp -label1 "Keep Image Ratio" subdProjectionSquareImage;
  387.  
  388.     separator;
  389. /*
  390. //createMap omitted for now
  391.  
  392.     checkBoxGrp -label1 "Create New UV Set" 
  393.         -on1 ("disable -v false subdProjectionUvSetName")
  394.         -of1 ("disable -v true subdProjectionUvSetName")
  395.         subdProjectionCreateMap;
  396.     textFieldGrp -label "UV Set Name" subdProjectionUvSetName;
  397. */
  398.     waitCursor -state 0;
  399.     setUITemplate -popTemplate;
  400.        
  401.     string $applyBtn = getOptionBoxApplyBtn();
  402.     button -edit -label "Project"
  403.            -command ($callback + 1)
  404.         $applyBtn;
  405.     string $saveBtn = getOptionBoxSaveBtn();
  406.     button -edit 
  407.         -command ($callback + 0 + "; hideOptionBox")
  408.         $saveBtn;
  409.     string $resetBtn = getOptionBoxResetBtn();
  410.     button -edit 
  411.         -command ($setup + 1)
  412.         $resetBtn;
  413.              
  414.     setOptionBoxTitle("Subdiv " + $primitive + " Mapping Options");
  415.  
  416.     setOptionBoxHelpTag( "SubdivPlanarMapping" );
  417.  
  418.     eval (($setup + 0));
  419.     showOptionBox();
  420. }
  421.  
  422. /*
  423. //createMap omitted for now
  424.  
  425. proc string setCurrentCmd(string $primitive, int $forceCreate, string $uvSetName)
  426. {
  427.     int $createNewMap =    `optionVar -q ("subdProjectionCreateMap" + $primitive)`;
  428.     string $setCurrent = "";
  429.     if ($createNewMap || $forceCreate)
  430.         $setCurrent = "subdUVSet -luv";
  431.     return $setCurrent;
  432. }
  433. */
  434.  
  435. //proc string assembleCmd(string $primitive, int $forceCreate, string $uvSetName)
  436. proc string assembleCmd(string $primitive)
  437. {
  438.     setOptionVars ($primitive, false);
  439.  
  440.     int $doHistory = `constructionHistory -q -toggle`;
  441.     float $ic[]=`optionVar -query ("subdProjectionImageCenter" + $primitive)`;
  442.     float $ir=`optionVar -query ("subdProjectionRotationAngle" + $primitive)`;
  443.     float $is[]=`optionVar -query ("subdProjectionImageScale" + $primitive)`;
  444.  
  445. //    int $createNewMap =    `optionVar -q ("subdProjectionCreateMap" + $primitive)`;
  446. //    string $mapname = `optionVar -q ("subdProjectionUvSetName" + $primitive)`;
  447.  
  448.  
  449. //    string $cmd=("subd" + $primitive + "Projection" + " -ch " + $doHistory);
  450.     string $cmd=("subdPlanarProjection -ch " + $doHistory );
  451.     if (`optionVar -query ("subdProjectionInsertionPoint" + $primitive)`)
  452.         $cmd+=(" -ibd on");
  453.     else $cmd+=(" -ibd off");
  454.  
  455.     $cmd+=(" -icx " + $ic[0] + " -icy " + $ic[1] +
  456.             " -ra " + $ir + 
  457.             " -isu " + $is[0] + " -isv " + $is[1]);
  458.  
  459. /*
  460. // createMap omitted for now
  461.  
  462.     if ($createNewMap || $forceCreate)
  463.     {
  464.         if ($forceCreate) $mapname = $uvSetName;
  465.         if (size($mapname))
  466.         {
  467.             $cmd = $cmd + (" -cm on -uvSetName " + $mapname);
  468.         }
  469.     }
  470. */
  471.  
  472.     int $fitToBoundingBox = 0, $fitToBestPlane = 0;
  473.  
  474.     if (`optionVar -q ("subdProjectionSmartFit" + $primitive)`) {
  475.         if ($primitive == "Planar") {
  476.             if (`optionVar -query ("subdProjectionSquareImage" + $primitive)`)
  477.                 $cmd+=(" -kir ");
  478.         } else {
  479.             $cmd+=(" -sf on ");
  480.             return $cmd;
  481.         }
  482.  
  483.         int $result=`optionVar -q ("subdProjectionFitToBoxOrPlane" + $primitive)`;
  484.         if ($result == 1) return ($cmd + " -md b");        //Best Plane
  485.         else if ($result == 2) {            //Bounding Box with direction
  486.             int $mdir = `optionVar -q ("subdProjectionMappingDirection" + $primitive)`;
  487.             switch ($mdir) {
  488.                 case 1: return ($cmd + " -md x ");
  489.                 case 2: return ($cmd + " -md y ");
  490.                 case 3: return ($cmd + " -md z ");
  491.                 case 4: return ($cmd + " -md c ");
  492.             }
  493.         }
  494.         //Should never reach this line
  495.     } else {
  496.         if ($primitive != "Planar") {
  497.             $cmd+=(" -sf off ");
  498.         }
  499.     }
  500.  
  501.     // Well, No smart fittings here.  Just pass those values to the command
  502.  
  503.     float $pc[]=`optionVar -query ("subdProjectionCenter" + $primitive)`;
  504.     float $pr[]=`optionVar -query ("subdProjectionRotate" + $primitive)`;
  505.  
  506.     $cmd+=(" -pcx " + $pc[0] + " -pcy " + $pc[1] + " -pcz " + $pc[2] + 
  507.            " -rx " + $pr[0] + " -ry  " + $pr[1] + " -rz  " + $pr[2]);
  508.  
  509.     if ($primitive == "Planar") {
  510. //        float $vals[2];
  511. //        $vals = `optionVar -query ("subdProjectionScale" + $primitive)`;
  512.         float $valU=`optionVar -query ("subdProjectionScaleU" + $primitive)`;
  513.         float $valV=`optionVar -query ("subdProjectionScaleV" + $primitive)`;
  514.         $cmd += (" -pw " + $valU + " -ph " + $valV);
  515.     } else {     
  516.         float $valU=`optionVar -query ("subdProjectionScaleU" + $primitive)`;
  517.         float $valV=`optionVar -query ("subdProjectionScaleV" + $primitive)`;
  518.         $cmd += (" -pw " + $valU + " -ph " + $valV);
  519.     }
  520.  
  521.     return $cmd;    
  522. }
  523.  
  524. /*
  525. // createMap omitted for now
  526.  
  527. proc string createCurrentShader ()
  528. {
  529.     global string $subdTextureColorShader;
  530.     string $shader;
  531.     string $shaderType="lambert";
  532.     string $textureName="checker";
  533.     if (`optionVar -q subdCreateShaderWithMapping` == 0) 
  534.         return "";
  535.     string $shader=`evalEcho "sets -n texturedFacets -em -r true -nss true"`;
  536.     if ($shader != "") {
  537.         evalEcho ("partition -e -addSet renderPartition " + $shader);
  538.         string $shad[];
  539.         if ($subdTextureColorShader != "")
  540.             $shad=`ls -showType $subdTextureColorShader`;
  541.         if ($subdTextureColorShader == "" || size($shad) == 0) {
  542.             string $texture[]=`ls -showType defaultSubdTexture`;
  543.             if (size($texture) == 0)
  544.                 $texture[0]=`evalEcho ("shadingNode -asTexture " 
  545.                         + $textureName + " -n defaultSubdTexture")`;            
  546.             $subdTextureColorShader=`evalEcho ("shadingNode -asShader " 
  547.                         + $shaderType + " -n defaultSubdShader")`;
  548.             evalEcho ("connectAttr " + $texture[0] + ".outColor " 
  549.                     + $subdTextureColorShader + ".color");
  550.             // creating a node selects it: we don't want that...
  551.             select -d $texture[0] $subdTextureColorShader;
  552.         }
  553.         $shad=`ls -showType $subdTextureColorShader`;
  554.         if ($subdTextureColorShader != "" && size($shad) != 0)
  555.             evalEcho ("connectAttr -f " + $subdTextureColorShader + ".outColor " 
  556.                                 + $shader + ".surfaceShader");
  557.         else warning "Could not create the default subd shader";
  558.     } else warning "Could not create a new set to hold the faces.";
  559.     return $shader;
  560. }
  561. */
  562.  
  563. proc concatArray(string $res[], string $to_add[])
  564. {
  565.     for($i in $to_add)
  566.         $res[size($res)] = $i;
  567. }
  568.  
  569. global proc string performSubdProjectionArgList 
  570.     (string $version, string $args[], string $uvSetName)
  571. //
  572. //    Input Arguments:
  573. //    $version: The version of this option box.  Used to know how to 
  574. //    interpret the $args array.
  575. //        "1" : $action, $primitive, $selectCmd
  576. //
  577. //    $args
  578. //    Version 1
  579. //    [0]        $action        0 : Execute the command.
  580. //                        1 : Show the option box dialog.
  581. //                        2 : Return the command.
  582. //    [1]        $primitive    The type of primitive to create
  583. //    [2]        $selectCmd    The command to issue to determine which objects
  584. //                            to affect
  585. //
  586. //    $uvSetName: The requested name for a new uv set
  587. //
  588. //  Return Value:
  589. //      The string to execute for this option box.
  590. //
  591. {
  592.     int        $versionNum                = $version;
  593.  
  594.     int        $action                    = $args[0];
  595.     string    $primitive                = $args[1];
  596.     string    $selectCmd                = $args[2];
  597. //    int        $forceCreate            = $args[3];
  598.  
  599.     string $cmd="";
  600.     string $lbl;
  601.     string $sel[], $preFilteredSel[];
  602.     switch ($action) {
  603.     case 0:
  604.         $preFilteredSel = `ls -sl`;
  605.         if (size($preFilteredSel) != 0) {
  606.             setOptionVars($primitive, false);
  607.             int $index=0;
  608.             string $oldnodes[]=`ls -sl -dep`;
  609.             if (size($oldnodes) > 0)
  610.                 select -d $oldnodes;
  611.  
  612.             string $totalSel[];
  613.  
  614.             // what is selected ?
  615.             concatArray($totalSel, `ls -sl`);
  616.  
  617.             // Do projections.
  618.  
  619. //            string $cmd=`assembleCmd $primitive $forceCreate $uvSetName`;
  620.             string $cmd=`assembleCmd $primitive`;
  621.  
  622.             for ($i = 0; $i < size($preFilteredSel); $i++)
  623.                 $cmd += (" " + $preFilteredSel[$i]);
  624.  
  625.             string $res[];
  626.             $res=`evalEcho $cmd`;
  627.             // append $res (nodes) to $totalSel
  628.             concatArray($totalSel, $res);
  629. /*
  630. // createMap omitted for now
  631.  
  632.             // Set current
  633.             string $setCurrent = `setCurrentCmd $primitive $forceCreate $uvSetName`;
  634.             if (size($setCurrent))
  635.             {
  636.                 for ($i = 0; $i < size($preFilteredSel); $i++)
  637.                     $setCurrent += (" " + $preFilteredSel[$i]);
  638.                 evalEcho $setCurrent;
  639.             }
  640. */
  641. //            string $shader=`createCurrentShader`;
  642. /*
  643.             // Update shader's set.
  644.             if( $shader != "") {
  645.                 $cmd=("sets -e -fe " + $shader);
  646.                 int $i;
  647.                 for($i=0; $i < size($preFilteredSel); $i++)
  648.                     $cmd=($cmd + " " + $preFilteredSel[$i]);
  649.                 evalEcho $cmd;
  650.             }
  651. */
  652.             // Set selection
  653.             evalEcho `select -r $totalSel`;
  654.  
  655.             // clear $sel;
  656.             global string $subdLastTool;
  657.             $subdLastTool="";
  658.             setToolTo ShowManips;
  659.  
  660.         } else warning("subdProjection works on subd faces.  Select them and invoke the command."); 
  661.         
  662.         break;
  663.  
  664.     case 1: subdProjectionOptions $primitive $args $uvSetName; break;
  665. /*
  666. // createMap omitted for now
  667.  
  668.     case 2: $cmd=`assembleCmd $primitive $forceCreate $uvSetName`;    
  669.       string $setCurrent = `setCurrentCmd $primitive $forceCreate $uvSetName`;
  670.       $cmd += ("; " + $setCurrent);
  671.       break;
  672. */
  673.     default:
  674.         // this is useless: setOptionVars(false);
  675.         $cmd = ("performSubdProjection " + $primitive + " 0");
  676.     }
  677.     return $cmd;
  678. }
  679.